﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GetWebInfo
{
    class Split
    {
        /* Split 文件格式
         * ***************************************************************************
         * 2011-06-30,A:5000
         * 2012-06-31,A:10000
         * 2013-07-01,A:10000
         * ***************************************************************************
         * 日期,A股股份数
         */
        public Split()
        {

        }

        public SortedList<DateTime, ulong> Splits
        {
            get
            {
                return this._ss;
            }
        }
        private SortedList<DateTime, ulong> _ss = new SortedList<DateTime, ulong>();

        public static Split Load(string fileName)
        {
            string _filePath = string.Format(@"{0}\{1}\Split",
                System.AppDomain.CurrentDomain.BaseDirectory,
                fileName);

            Split _sp = new Split();
            using (StreamReader sr = new StreamReader(_filePath))
            {
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    if (line != "")
                    {
                        string[] _strs = line.Split(new char[] { ',', ':' });
                        _sp._ss.Add(DateTime.Parse(_strs[0]), ulong.Parse(_strs[2]));
                    }
                }
            }

            return _sp;
        }
    }
}
